﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace BSEntities
{
    public abstract class SkillModifier:GameComponent
    {
        /// <summary>
        /// The time the SkillModifier was added
        /// </summary>
        public float TimeSinceAdded { get; set; }

        public float ElapsedTimeForValueIncrementor { get; set; }

        /// <summary>
        /// The time for the skil modifier to stay effective. -1 to make it permanent.
        /// </summary>
        public float TimeToStayActive { get; set; }

        /// <summary>
        /// Time To increment ValueChanger on Value. -1 to skip functioanlity
        /// </summary>
        public float TimeToChangeValue { get; set; }

        /// <summary>
        /// The value to increment onto Value when TimeToChangeValue 
        /// </summary>
        public float ValueChanger { get; set; }

        public string Description { get; set; }

        public float Value { get; set; }



        public override void Update(GameTime gameTime)
        {
            TimeSinceAdded += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            ElapsedTimeForValueIncrementor += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (TimeToStayActive <= TimeSinceAdded && TimeToStayActive != -1)
            {
                Enabled = false;
            }
            else
            {
                if (TimeToChangeValue <= ElapsedTimeForValueIncrementor && TimeToChangeValue != -1)
                {
                    Value += ValueChanger;
                    ElapsedTimeForValueIncrementor = 0;
                }

            }
            base.Update(gameTime);
        }
    }
}
